package com.fhminyi.util;

import com.fhminyi.model.Product;
import java.io.File;
import java.io.IOException;

public class ProductImageUploadUtil {
    private static final String UPLOAD_DIR = "res/img";

    public static void uploadProductImage(File imageFile, Product product) throws IOException {
        String fileName = imageFile.getName();
        FileUploadUtil.uploadFile(UPLOAD_DIR, fileName, java.nio.file.Files.readAllBytes(imageFile.toPath()));
        product.setImageLocation(UPLOAD_DIR + "/" + fileName);
    }
}